﻿using Knowledge.EF.Back.Models;
using Knowledge.EF.Back.Models.DB;
using Knowledge.EF.Back.Models.Users;
using MediatR;

namespace Knowledge.EF.Back.DAL.Users
{
    public class UserListHandler : IRequestHandler<UserList, BaseResult>
    {
        private readonly EFCoreContext _context; //构造一个只读的变量

        public UserListHandler(EFCoreContext context) //创造一个构造函数 当引用_context时就会引用这函数
        {
            _context = context;
        }
        public Task<BaseResult> Handle(UserList request, CancellationToken cancellationToken)
        {
            var listUser = from list in _context.Users//linq查询语句
                           select list;
            return Task.FromResult(new BaseResult { Code = 200, Message = "登陆成功", Data = listUser });
        }
    }
}
